package oop.ex3.filemanager;

import java.util.Comparator;


//TODO javaDoc and add necessary methods.
/**
 * Represents a file that can be uploaded.
 * monitors uploaders number, the ability to upload the file.
 */
public class UploadFile implements Comparable<UploadFile>{
	private String _fileName;
	//private volatile int _uploadsCounter;
	private volatile boolean _isUploadable;
	//private static final int NOT_UPLOADED=0;
	
	/**
	 * Constructs a new UploadableFile object.
	 * Sets the fileName to the given parameter,
	 * and sets the current uploads number to NOT_UPLOADED.
	 * @param fileName the wanted filename of this UploadableFile.
	 */
	public UploadFile(String fileName){
		this._fileName = fileName;
		//this._uploadsCounter = NOT_UPLOADED;
		this._isUploadable=true;
	}
	
	public String getName(){
		return this._fileName;
	}
	
	//public synchronized void addUploader(){
		//if (_isUploadable){
		//_uploadsCounter = _uploadsCounter + 1;
		//}
	//}
	
	/*
	public synchronized void removeUploader(){
		_uploadsCounter = _uploadsCounter - 1;
	}*/
	
	/*
	public synchronized int getNumberOfUploads(){
		return this._uploadsCounter;
	}*/
	
	/**
	 * Changes this UploadableFile status to not-uploadable.
	 */
	public synchronized void setNotUploadable(){
		this._isUploadable=false;
	}
	
	public synchronized void setUploadable(){
		this._isUploadable=true;
	}
	
	public synchronized boolean isUploadable(){
		return this._isUploadable;
	}	
	
	@Override
	public int compareTo(UploadFile otherFile) {
		return this._fileName.compareTo(otherFile._fileName);
	}
	
}
